package mvc.Model.Bbs;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.ibatis.sqlmap.client.SqlMapClient;
import common.sqlmap.GetSqlMapClient;

public class BbsCMTDataDAO {
	private SqlMapClient sqlMapClient;      
	
	public BbsCMTDataDAO() {
	    super();
	    sqlMapClient = GetSqlMapClient.get();
	}

	public List list(Map map) throws SQLException {
		return sqlMapClient.queryForList("bbscmtdata.list", map);
	}

	public boolean create(BbsCMTDataDTO dto) throws SQLException {
		boolean flag = false;
		int cnt = (Integer)sqlMapClient.insert("bbscmtdata.create", dto);
		if(cnt>0) flag = true;
		return flag;
	}

	public int getCount(Map map) throws SQLException {
		return (Integer)sqlMapClient.queryForObject("bbscmtdata.getCount",map);
	}

	public boolean update(BbsCMTDataDTO dto) throws SQLException {
		boolean flag = false;
		Object obj = null;
		try{
			obj = sqlMapClient.update("bbscmtdata.update", dto);
			if(obj != null)
				flag = true;
		}catch(Exception e){
			System.out.println(e.toString());
		}
		return flag;
	}

	public BbsCMTDataDTO read(int cmt_seq) throws SQLException {
		return (BbsCMTDataDTO)sqlMapClient.queryForObject("bbscmtdata.read", cmt_seq);
	}

	public boolean delete(int cmt_seq) throws SQLException {
		boolean flag = false;
		int cnt = (Integer)sqlMapClient.delete("bbscmtdata.delete", cmt_seq);
		if(cnt>0) flag = true;
		return flag;
	}

}
